﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class login_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void login_Click(object sender, EventArgs e)
    {
        if (tbuser.Text.Trim() == "Aaron" && tbpass.Text.Trim() == "123")
        {
           // FormsAuthentication.SetAuthCookie("Aaron", false);
            string roles="1|2|3|4";
            FormsAuthenticationTicket ft = new FormsAuthenticationTicket(1, tbuser.Text, DateTime.Now, DateTime.Now.AddMinutes(2), false, roles);
            
            string encry = FormsAuthentication.Encrypt(ft);
            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encry));
            
        }
        else {
            Response.Redirect(FormsAuthentication.GetRedirectUrl(tbuser.Text.Trim(), false), true);
        }
    }
}
